<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统信息监控</title>
    <style type="text/css">
        * {
            padding: 0;
            margin: 0;
        }
    
        html,
        body {
            height: 100%;
        }
    
        body {
            background: url('333.png') center/cover no-repeat fixed;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: 'Microsoft YaHei', sans-serif;
        }
    
        .dashboard {
            width: 400px;
            height: auto;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.3);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.6);
            padding: 20px;
            box-sizing: border-box;
        }
    
        .dashboard h1 {
            font-size: 30px;
            text-align: center;
            color: #333;
            margin-bottom: 10px;
        }
        
        .dashboard p {
            text-align: center;
            color: #666;
            margin-bottom: 20px;
        }
    
        .data-panel {
            width: 100%;
            margin: 0 auto;
        }
    
        .data-panel form input[type="text"] {
            width: 100%;
            height: 40px;
            outline: none;
            margin: 10px auto;
            border-radius: 5px;
            border: 1px solid rgba(0, 0, 0, 0.1);
            background: rgba(255, 255, 255, 0.8);
            padding: 0 10px;
            box-sizing: border-box;
            font-size: 14px;
        }
        
        .data-panel label {
            display: block;
            margin-top: 15px;
            color: #333;
            font-size: 14px;
        }
    
        .button-group {
            text-align: center;
            margin-top: 20px;
        }
    
        .refresh-btn {
            line-height: 40px;
            height: 40px;
            width: 100%;
            color: #3d3c3ccf;
            background-color: rgba(50, 50, 50, 0.8);
            font-size: 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s;
        }
    
        .refresh-btn:hover {
            background-color: rgba(50, 50, 50, 0.9);
            color: #f1ececcf;
        }
        
        .nav-links {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 20px;
            font-size: 14px;
            color: #666;
        }
        
        .nav-links a {
            color: #666;
            text-decoration: none;
            transition: color 0.3s;
        }
        
        .nav-links a:hover {
            color: #333;
        }

        .footer {
            position: fixed;
            bottom: 0;
            width: 100%;
            height: 50px;
            font-size: 12px;
            text-align: center;
            font-family: "宋体";
            color: rgba(255, 255, 255, 0.8);
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
        }
    </style>
</head>
<body>
    <div class="dashboard">
        <h1>系统信息监控</h1>
        <p>实时系统状态监测</p>
        
        <div class="data-panel">
            <form>
                <label>主机名</label>
                <input type="text" id="hostname" value="Linux" readonly/>
                
                <label>固件版本</label>
                <input type="text" id="firmware" value="v1.0" readonly/>
                
                <label>本地时间</label>
                <input type="text" id="localtime" readonly/>
                
                <label>运行时间</label>
                <input type="text" id="uptime" readonly/>
                
                <div class="button-group">
                    <button type="button" class="refresh-btn" onclick="updateSystemInfo()">刷新数据</button>
                </div>
            </form>
        </div>
        
        <div class="nav-links">
            <a href="mainpage.html">主页</a>
            <a href="stm32.html">STM32</a>
            <a href="modbusslave.html">Modbus Slave</a>
            <a href="modeselect.html">模式选择</a>
            <a href="http://192.168.43.241:8080/stream_simple.html">视频监控</a>
        </div>
    </div>
    <div class="footer">
        联系电话: 400-706-1880 &nbsp 技术支持QQ: 1075518049<br>
        开发商：华清远见济南研发中心
    </div>

    <script>
        // 初始化系统信息
        function updateSystemInfo() {
            // 获取当前时间
            const now = new Date(); // 使用当前时间
            document.getElementById('localtime').value =    // 格式化时间
                `${now.getFullYear()}-${padZero(now.getMonth()+1)}-${padZero(now.getDate())} ` +
                `${padZero(now.getHours())}:${padZero(now.getMinutes())}:${padZero(now.getSeconds())}`;
            
            // 模拟运行时间（实际应从后端获取）
            const uptimeElement = document.getElementById('uptime');
            let seconds = parseInt(uptimeElement.value) || 0;
            if(!uptimeElement.value.includes("天")) {
                seconds = Math.floor(Math.random() * 86400); // 初始化随机值
            } else {
                seconds += 1; // 每次刷新增加1秒
            }
            
            const days = Math.floor(seconds / 86400);
            const hours = Math.floor((seconds % 86400) / 3600);
            const mins = Math.floor((seconds % 3600) / 60);
            const secs = seconds % 60;
            
            uptimeElement.value = `${days}天 ${padZero(hours)}:${padZero(mins)}:${padZero(secs)}`;
        }

        // 补零函数
        function padZero(num) {
            return num < 10 ? `0${num}` : num;
        }

        // 页面加载时初始化
        window.onload = function() {
            updateSystemInfo();
            // 每秒自动更新时间
            setInterval(() => {
                document.getElementById('localtime').value = getCurrentTime();
                updateUptime();
            }, 1000);
        };

        // 获取当前格式化时间
        function getCurrentTime() {
            const now = new Date();
            return `${now.getFullYear()}-${padZero(now.getMonth()+1)}-${padZero(now.getDate())} ` +
                   `${padZero(now.getHours())}:${padZero(now.getMinutes())}:${padZero(now.getSeconds())}`;
        }

        // 更新运行时间
        function updateUptime() {
            const uptimeElement = document.getElementById('uptime');
            if(uptimeElement.value) {
                let [days, time] = uptimeElement.value.split('天');
                let [hours, mins, secs] = time.trim().split(':').map(Number);
                
                // 增加1秒
                secs += 1;
                if(secs >= 60) {
                    secs = 0;
                    mins += 1;
                }
                if(mins >= 60) {
                    mins = 0;
                    hours += 1;
                }
                if(hours >= 24) {
                    hours = 0;
                    days = parseInt(days) + 1;
                }
                
                uptimeElement.value = `${days}天 ${padZero(hours)}:${padZero(mins)}:${padZero(secs)}`;
            }
        }
    </script>
</body>
</html>